solving Stanford University question